package com.scalesoft.artsync;

import java.util.Vector;

import com.scalesoft.artsync.frontend.controller.FrontendController;
import com.scalesoft.artsync.frontend.controller.FrontendControllerImpl;
import com.scalesoft.artsync.frontend.view.FrontendView;
import com.scalesoft.artsync.frontend.view.FrontendViewImpl;
import com.scalesoft.artsync.plugins.util.Log;
import com.scalesoft.artsync.util.ClassFinder;

public class ArtSyncApplication {

	FrontendController controller;
	FrontendView view;
	
	public ArtSyncApplication() {
		
		ClassFinder finder = new ClassFinder();
    	Vector<Class<?>> v = null;
		
		finder = new ClassFinder ();
		v = finder.findSubclasses ("com.scalesoft.artsync.plugins.Exporter");

		Log.i(this, "Discovering Exporter Plugins:");
		if (v != null && v.size () > 0)
			for (Class<?> cls : v)
				Log.i(this, cls.toString());

		v = finder.findSubclasses ("com.scalesoft.artsync.plugins.Importer");
		Log.i(this, "Discovering Importer Plugins:");
		if (v != null && v.size () > 0)
			for (Class<?> cls : v)
				Log.i(this, cls.toString());

		view = new FrontendViewImpl();
		controller = new FrontendControllerImpl(view);
	}
	
	protected void showApplicationWindow() {
		view.showWindow();
	}
	
	public void run() {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                showApplicationWindow();
            }
        });

	}
	
}
